package triEngine;

import transaction.*;
import triBasic.*;
import triIndex.*;
import triInstance.*;
import java.util.*;

class NodeInfoSet implements ISet<NodeInfo> {
	
	Vector<NodeInfo> set;

	int pos;
	
	public NodeInfoSet(ISet<Integer> intSet, IndexManager index, Transaction tx) {
		pos = 0;
		set = new Vector<NodeInfo> ();
		while (true) {
			Integer nodeId = intSet.nextItem();
			if (nodeId == null)
				break;
			else {
				NodeSnapshot snapshot = index.getNodeSnapshot(nodeId, tx);
				if (snapshot == null)
					break;
				set.add(new NodeInfo(snapshot.getNodeId(), snapshot.getTagName()));
			}
		}
	}
	
	
	public NodeInfo nextItem() {
		if (pos >= set.size())
			return null;
		return set.get(pos++);
	}
}